<style lang="less">
	.fanlifangan{
		padding:10px;
		background: #fff;
		h3{font-size: 14px;padding: 5px 0;}
		p{
			padding: 5px 0;
			text-indent: 20px;
			line-break: 20px; color:#909399; font-size: 14px;
			span{
				font-size: 16px; font-family: Arial;padding:0 3px; color:#F56C6C
			}
		}
	}
</style>

<template>
	<div v-loading="loading">
    	<load-more v-if="form.length == 0" :show-loading="false" tip="暂无相关会员权益" background-color="#fbf9fe"></load-more>
		<div v-else class="fanlifangan">
			<h3>返利方案</h3>
			<div v-html="text"></div>
		</div>
    <back></back>
	</div>
</template>

<script>
	import { Panel } from 'vux'
  import back from '@/components/back/backPrev';
	export default {
		directives: {

		},
		components:{
			Panel,
      back
		},
		data(){
			return {
				loading : false,
				form : {}
			}
		},
		methods : {
			initdata(){
				this.loading = true;
				this.$http.member.get('fanliSet/getQuanyi').then(res => {
					if(!res.data.code){
						this.form = res.data.data;
					}
					this.loading = false;
				})
          .catch(err => {
            this.$message({
              message: '登陆过期，请重新登陆！',
              type: 'error'
            });
            localStorage.removeItem('user');
            localStorage.removeItem('company');
            localStorage.removeItem('api_token');
            localStorage.removeItem('refresh_token');
            location.reload()
          })
			},

		},
		computed : {
			//条件1
			fangan1_tj1(){
				return this.form.days != 0 && this.form.manjian != 0 && this.form.bilv != 0
			},
			//条件2
			fangan1_tj2(){
				return this.fangan1_tj1 && this.form.start2 != 0 && this.form.bilv2 != 0
			},
			//条件3
			fangan1_tj3(){
				return this.fangan1_tj2 && this.form.start3 != 0 && this.form.bilv3 != 0
			},
			text(){
				let str = '';
				if(this.form.fangan == 1){
					str += '<p>在会员消费周期<span>'+this.form.days+'</span>天内，会员购买件数满<span>'+this.form.manjian+'</span>件，立即将合计积分的<span>'+this.form.bilv+'</span>%转换为现金（劵）作为返利。</p>';
					if(this.fangan1_tj2){
						str += '<p>在会员消费周期第<span>'+this.form.days+'</span>天时，购买件数未满<span>'+this.form.manjian+'</span>件，但达到<span>'+this.form.start2+'</span>件,即将合计积分的<span>'+this.form.bilv2+'</span>%转换为现金（劵）作为返利。</p>';
					}
					if(this.fangan1_tj3){
						str += '<p>在会员消费周期第<span>'+this.form.days+'</span>天时，购买件数未满<span>'+this.form.start2+'</span>件，但达到<span>'+this.form.start3+'</span>件,即将合计积分的<span>'+this.form.bilv3+'</span>%转换为现金（劵）作为返利。</p>';
					}
				}else if(this.form.fangan == 2){
					str += '<p>当合计件数达到返利条件(<span>'+this.form.manjian+'</span>件)时，系统会自动进行返利，将积分(<span>'+this.form.bilv+'</span>%)转换为现金并上账到会员账户并清零积分重新累计</p>';
				}else if(this.form.fangan == 3){
					str += '<p>在会员消费周期<span>'+this.form.days+'</span>天内，会员购买积分满<span>'+this.form.manjian+'</span>分，立即将合计积分的<span>'+this.form.bilv+'</span>%转换为现金（劵）作为返利。</p>';
					if(this.fangan1_tj2){
						str += '<p>在会员消费周期第<span>'+this.form.days+'</span>天时，购买积分未满<span>'+this.form.manjian+'</span>分，但达到<span>'+this.form.start2+'</span>分,即将合计积分的<span>'+this.form.bilv2+'</span>%转换为现金（劵）作为返利。</p>';
					}
					if(this.fangan1_tj3){
						str += '<p>在会员消费周期第<span>'+this.form.days+'</span>天时，购买积分未满<span>'+this.form.start2+'</span>分，但达到<span>'+this.form.start3+'</span>分,即将合计积分的<span>'+this.form.bilv3+'</span>%转换为现金（劵）作为返利。</p>';
					}
				}else if(this.form.fangan == 4){
					str += '<p>会员购买无时间限制，只要累计积分满<span>'+this.form.manjf+'</span>分，返现金（劵）<span>'+this.form.jfcash+'</span>元。</p>';
				}else if(this.form.fangan == 5){
					str += '<p>统一返利日期(周期按年)，累计积分至少达到<span>'+this.form.manjf+'</span>分，立即将累计积分的<span>'+this.form.bilv+'</span>%转换为现金（劵）作为返利。</p>';
				}
				return str;
			}
		},
		created(){
			this.initdata();
		},
		watch : {

		}
	}
</script>
